import {query,login,remove,update} from "../services/login";
import { routerRedux } from 'dva/router'
import CookieConfig from '../assets/js/CookieConfig'
export default{
    namespace: 'login',
    state:{
        userInfo:{}
    },
    effects: {
        *login({ payload }, { call, put }) {
           const data =  yield call(login,payload);
           if(data.status === 0){
               let params = {
                   name:'token',
                   value:data.data.role
               }
               CookieConfig.saveCookie(params)
               yield put({
                   type:"app/query",
                   payload:data.data
               })
               yield put(routerRedux.push('/dashboard'))
           }else{
               throw data;
           }
        }
    },
    reducers: {

    }
}

